<template>
  <div class="error-page">
    <div class="error-container">
      <div class="error-content">
        <div class="error-image">
          <svg viewBox="0 0 404 300" class="error-svg">
            <!-- 404数字 -->
            <text x="50%" y="50%" text-anchor="middle" dominant-baseline="middle" class="error-text">
              404
            </text>
            
            <!-- 装饰元素 -->
            <circle cx="100" cy="80" r="8" class="decoration-circle" />
            <circle cx="320" cy="220" r="6" class="decoration-circle" />
            <rect x="80" y="200" width="15" height="15" class="decoration-rect" />
            <rect x="300" y="60" width="12" height="12" class="decoration-rect" />
            
            <!-- 波浪线 -->
            <path d="M50 150 Q100 130 150 150 T250 150" stroke="#e6f7ff" stroke-width="3" fill="none" class="wave-line" />
            <path d="M150 250 Q200 230 250 250 T350 250" stroke="#f0f9ff" stroke-width="2" fill="none" class="wave-line" />
          </svg>
        </div>
        
        <div class="error-info">
          <h1 class="error-title">页面不存在</h1>
          <p class="error-description">
            抱歉，您访问的页面不存在或已被移除。
          </p>
          <p class="error-suggestion">
            请检查URL是否正确，或返回首页继续浏览。
          </p>
          
          <div class="error-actions">
            <el-button type="primary" @click="goHome">
              <el-icon><House /></el-icon>
              返回首页
            </el-button>
            <el-button @click="goBack">
              <el-icon><ArrowLeft /></el-icon>
              返回上页
            </el-button>
            <el-button @click="refresh">
              <el-icon><Refresh /></el-icon>
              刷新页面
            </el-button>
          </div>
        </div>
      </div>
      
      <!-- 帮助信息 -->
      <div class="help-section">
        <el-card class="help-card">
          <template #header>
            <div class="help-header">
              <el-icon><QuestionFilled /></el-icon>
              <span>可能的原因</span>
            </div>
          </template>
          
          <ul class="help-list">
            <li>页面链接已过期或被删除</li>
            <li>URL地址输入错误</li>
            <li>您没有访问该页面的权限</li>
            <li>服务器临时维护中</li>
          </ul>
        </el-card>
        
        <el-card class="help-card">
          <template #header>
            <div class="help-header">
              <el-icon><Tools /></el-icon>
              <span>解决方案</span>
            </div>
          </template>
          
          <ul class="help-list">
            <li>检查并重新输入正确的URL</li>
            <li>使用导航菜单访问其他页面</li>
            <li>联系管理员获取帮助</li>
            <li>稍后再试或刷新页面</li>
          </ul>
        </el-card>
      </div>
      
      <!-- 快速导航 -->
      <div class="quick-nav">
        <h3>快速导航</h3>
        <div class="nav-links">
          <el-button text @click="navigateTo('/dashboard')">
            <el-icon><Monitor /></el-icon>
            控制台
          </el-button>
          <el-button text @click="navigateTo('/questions')">
            <el-icon><Document /></el-icon>
            题目管理
          </el-button>
          <el-button text @click="navigateTo('/papers')">
            <el-icon><Notebook /></el-icon>
            试卷管理
          </el-button>
          <el-button text @click="navigateTo('/students')">
            <el-icon><User /></el-icon>
            学生管理
          </el-button>
          <el-button text @click="navigateTo('/statistics')">
            <el-icon><DataAnalysis /></el-icon>
            数据统计
          </el-button>
          <el-button text @click="navigateTo('/settings')">
            <el-icon><Setting /></el-icon>
            系统设置
          </el-button>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { useRouter } from 'vue-router'
import { ElMessage } from 'element-plus'
import {
  House,
  ArrowLeft,
  Refresh,
  QuestionFilled,
  Tools,
  Monitor,
  Document,
  Notebook,
  User,
  DataAnalysis,
  Setting
} from '@element-plus/icons-vue'

const router = useRouter()

// 返回首页
const goHome = () => {
  router.push('/')
}

// 返回上一页
const goBack = () => {
  if (window.history.length > 1) {
    router.go(-1)
  } else {
    router.push('/')
  }
}

// 刷新页面
const refresh = () => {
  window.location.reload()
}

// 导航到指定页面
const navigateTo = (path) => {
  router.push(path).catch(() => {
    ElMessage.warning('页面暂时无法访问')
  })
}
</script>

<style scoped>
.error-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.error-container {
  max-width: 1200px;
  width: 100%;
}

.error-content {
  background: white;
  border-radius: 16px;
  padding: 60px 40px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.1);
  text-align: center;
  margin-bottom: 40px;
}

.error-image {
  margin-bottom: 40px;
}

.error-svg {
  width: 100%;
  max-width: 400px;
  height: 200px;
}

.error-text {
  font-size: 80px;
  font-weight: bold;
  fill: #409eff;
  font-family: 'Arial', sans-serif;
}

.decoration-circle {
  fill: #e6f7ff;
  animation: float 3s ease-in-out infinite;
}

.decoration-rect {
  fill: #f0f9ff;
  animation: float 3s ease-in-out infinite reverse;
}

.wave-line {
  animation: wave 4s ease-in-out infinite;
}

@keyframes float {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

@keyframes wave {
  0%, 100% {
    opacity: 0.5;
  }
  50% {
    opacity: 1;
  }
}

.error-info {
  max-width: 600px;
  margin: 0 auto;
}

.error-title {
  font-size: 32px;
  color: #303133;
  margin-bottom: 16px;
  font-weight: 600;
}

.error-description {
  font-size: 18px;
  color: #606266;
  margin-bottom: 12px;
  line-height: 1.6;
}

.error-suggestion {
  font-size: 16px;
  color: #909399;
  margin-bottom: 40px;
  line-height: 1.6;
}

.error-actions {
  display: flex;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
}

.help-section {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
  margin-bottom: 40px;
}

.help-card {
  background: white;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

.help-header {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #409eff;
  font-weight: 600;
}

.help-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.help-list li {
  padding: 8px 0;
  color: #606266;
  position: relative;
  padding-left: 20px;
}

.help-list li::before {
  content: '•';
  color: #409eff;
  position: absolute;
  left: 0;
  font-weight: bold;
}

.quick-nav {
  background: white;
  border-radius: 12px;
  padding: 30px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  text-align: center;
}

.quick-nav h3 {
  margin: 0 0 20px 0;
  color: #303133;
  font-size: 20px;
  font-weight: 600;
}

.nav-links {
  display: flex;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
}

.nav-links .el-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 16px 20px;
  border-radius: 8px;
  transition: all 0.3s;
}

.nav-links .el-button:hover {
  background: #f5f7fa;
  transform: translateY(-2px);
}

/* 响应式设计 */
@media (max-width: 768px) {
  .error-content {
    padding: 40px 20px;
  }
  
  .error-title {
    font-size: 24px;
  }
  
  .error-description {
    font-size: 16px;
  }
  
  .error-actions {
    flex-direction: column;
    align-items: center;
  }
  
  .error-actions .el-button {
    width: 200px;
  }
  
  .help-section {
    grid-template-columns: 1fr;
  }
  
  .nav-links {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  
  .nav-links .el-button {
    padding: 12px 16px;
    font-size: 14px;
  }
}

@media (max-width: 480px) {
  .error-page {
    padding: 10px;
  }
  
  .error-text {
    font-size: 60px;
  }
  
  .quick-nav {
    padding: 20px;
  }
  
  .nav-links {
    grid-template-columns: 1fr;
  }
}
</style>